<?php
    use User\Model\LpicModel;
?>
<!-- page heading start-->
<div class="page-heading">
    <h3>
        <a href="/User/Lpic/index">直播列表</a>->用户列表
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">
                <a class="btn btn-default" href="<?php echo '/User/Lpic/registerUpdate?liveId=' . I('get.id', '', '');?>">增加</a>
            </header>
            <div class="panel-body">
                <input type="hidden" value="<?php echo I('get.id', '', '');?>" id="liveId">
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="12%">姓名</th>
                        <th width="12%">昵称</th>
                        <th width="12%">手机号</th>
                        <th width="15%">用户单位</th>
                        <th width="15%">创建时间</th>
                        <th width="12%">状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span>
                                <?php echo $val['name'];?>
                            </span>
                        </td>
                        <td>
                            <span >
                                <?php
                                echo $val['nickname'];
                                ?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php
                                echo $val['phone'];
                                ?>
                            </span>
                        </td>
                        <td>
                            <span style="word-wrap:break-word">
                                <?php
                                echo $val['company'];
                                ?>
                            </span>
                        </td>
                        <td>
                            <span >
                                <?php
                                echo $val['added_date'];
                                ?>
                            </span>
                        </td>
                        <td>
                            <span >
                                <?php
                                echo LpicModel::getStatus($val['status']);
                                ?>
                            </span>
                        </td>
                        <td>
                            <div>
                                <div>
                                    <a class="btn btn-success"
                                       href="<?php echo '/User/Lpic/registerUpdate?type=update&liveId=' . $val['live_id'] . '&userId=' . $val['user_id'];?>">编辑</a>
                                    <a class="btn btn-danger" href="#"
                                       onclick="<?php echo 'return delete_data(' . $val['user_id'] .')';?>">删除</a>
                                </div>
                                <div style="margin-top: 10px;">
                                    <a class="btn btn-info" href="#"
                                       onclick="<?php echo 'return active_data(' . $val['user_id'] .')';?>">通过</a>
                                    <a class="btn btn-warning" href="#"
                                       onclick="<?php echo 'return pending_data(' . $val['user_id'] .')';?>">待审核</a>
                                    <a class="btn btn-default" href="#"
                                       onclick="<?php echo 'return reject_data(' . $val['user_id'] .')';?>">不通过</a>

                                </div>
                            </div>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>

<script>
    function active_data(id){
        $.ajax({
            data:{userId:id},
            dataType:'json',
            url:'/User/Lpic/registerActive',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function pending_data(id){
        $.ajax({
            data:{userId:id},
            dataType:'json',
            url:'/User/Lpic/registerPend',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function reject_data(id){
        $.ajax({
            data:{userId:id},
            dataType:'json',
            url:'/User/Lpic/registerReject',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function delete_data(id){
        $.ajax({
            data:{userId:id},
            dataType:'json',
            url:'/User/Lpic/registerDelete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
</script>